package com.factors.ZhangDingHou.Distance_from_Home;

import org.apache.hadoop.conf.Configuration;
import org.apache.hadoop.fs.Path;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Job;
import org.apache.hadoop.mapreduce.lib.input.FileInputFormat;
import org.apache.hadoop.mapreduce.lib.output.FileOutputFormat;

public class DistanceFromHomeCountDriver {

    public static void main(String[] args) throws Exception {

        Configuration conf = new Configuration();
        Job job = Job.getInstance(conf, "Distance From Home Count");
        job.setJarByClass(DistanceFromHomeCountDriver.class);

        job.setMapperClass(DistanceFromHomeCountMapper.class);
        job.setReducerClass(DistanceFromHomeCountReducer.class);

        job.setOutputKeyClass(Text.class);
        job.setOutputValueClass(DistanceFromHomeCount.class);

        FileInputFormat.addInputPath(job, new Path("Data/part-m-00000"));
        FileOutputFormat.setOutputPath(job, new Path("output/Zhang/Distance_from_Home"));

        System.exit(job.waitForCompletion(true) ? 0 : 1);
    }
}